package com.dt.platform.generator.module.oa;

import com.dt.platform.constants.db.OaTables;
import com.dt.platform.domain.oa.ProjectDoc;
import com.dt.platform.generator.config.Config;
import com.dt.platform.oa.page.ProjectDocPageController;
import com.dt.platform.proxy.oa.ProjectDocServiceProxy;
import com.github.foxnic.generator.config.WriteMode;
import org.github.foxnic.web.domain.hrm.Employee;
import org.github.foxnic.web.domain.storage.File;

public class AProjectDocGtr extends BaseCodeGenerator {


    public AProjectDocGtr() {
        super(OaTables.OA_PROJECT_DOC.$TABLE,"705020984087805957");
    }

    public void generateCode() throws Exception {
        System.out.println(this.getClass().getName());

        cfg.view().field(OaTables.OA_PROJECT_DOC.ID).basic().hidden(true);
        cfg.view().field(OaTables.OA_PROJECT_DOC.CT).search().fuzzySearch();

        cfg.getPoClassFile().addSimpleProperty(Employee.class,"owner","owner","owner");
        cfg.getPoClassFile().addSimpleProperty(File.class,"docFile","docFile","docFile");
        cfg.view().search().inputLayout(
                new Object[]{
                        OaTables.OA_PROJECT_DOC.CT,
                }
        );


        cfg.view().field(OaTables.OA_PROJECT_DOC.UPDATE_BY).table().disable(true);
        cfg.view().field(OaTables.OA_PROJECT_DOC.UPDATE_BY).table().disable(true);
        cfg.view().field(OaTables.OA_PROJECT_DOC.CREATE_BY).table().disable(true);
        cfg.view().field(OaTables.OA_PROJECT_DOC.PROJECT_ID).table().disable(true);
        cfg.view().list().disableBatchDelete();

        cfg.view().search().labelWidth(1,Config.searchLabelWidth);
        cfg.view().search().labelWidth(2,Config.searchLabelWidth);
        cfg.view().search().labelWidth(3,Config.searchLabelWidth);
        cfg.view().search().labelWidth(4,Config.searchLabelWidth);
        cfg.view().search().inputWidth(Config.searchInputWidth);

        cfg.view().form().labelWidth(88);
        cfg.view().field(OaTables.OA_PROJECT_DOC.OWNER_ID).table().fillBy("owner","name");
        cfg.view().field(OaTables.OA_PROJECT_DOC.OWNER_ID).form()
                .button().chooseEmployee(true);


        cfg.view().field(OaTables.OA_PROJECT_DOC.FILE_ID).form().validate().required().form().upload().acceptAllType().maxFileCount(3);
        cfg.view().list().columnLayout(OaTables.OA_PROJECT_DOC.FILE_ID,OaTables.OA_PROJECT_DOC.CT,OaTables.OA_PROJECT_DOC.OWNER_ID,OaTables.OA_PROJECT_DOC.CREATE_TIME);

        cfg.view().field(OaTables.OA_PROJECT_DOC.CT).form().textArea().height(80);
        cfg.view().formWindow().bottomSpace(50);
        cfg.view().formWindow().width(Config.baseFormWidth_50);


        cfg.view().form().addGroup(null,
                new Object[] {
                        OaTables.OA_PROJECT_DOC.FILE_ID,
                        OaTables.OA_PROJECT_DOC.CT,
                }
        );
        cfg.view().list().addJsVariable("PAGE_TYPE","[[${pageType}]]","pageType");
        cfg.view().list().addJsVariable("PROJECT_ID","[[${projectId}]]","projectId");
        cfg.view().form().addJsVariable("PROJECT_ID","[[${projectId}]]","projectId");


        //文件生成覆盖模式
        cfg.overrides()
                .setServiceIntfAnfImpl(WriteMode.IGNORE) //服务与接口
                .setControllerAndAgent(WriteMode.IGNORE) //Rest
                .setPageController(WriteMode.IGNORE) //页面控制器
                .setFormPage(WriteMode.COVER_EXISTS_FILE) //表单HTML页
                .setListPage(WriteMode.COVER_EXISTS_FILE)
                .setExtendJsFile(WriteMode.IGNORE); //列表HTML页

//        cfg.overrides().setServiceIntfAnfImpl(WriteMode.IGNORE);
//        cfg.overrides().setControllerAndAgent(WriteMode.IGNORE);
//        cfg.overrides().setPageController(WriteMode.IGNORE);
//        cfg.overrides().setExtendJsFile(WriteMode.WRITE_TEMP_FILE);

        //列表HTML页
        //生成代码
        cfg.buildAll();
    }

    public static void main(String[] args) throws Exception {
        AProjectDocGtr g=new AProjectDocGtr();
        //生成代码
        g.generateCode();

        //移除之前生成的菜单，视情况执行
//        g.removeByBatchId("471622036347682816");
        //生成菜单
       // g.generateMenu(ProjectDocServiceProxy.class, ProjectDocPageController.class);
    }

}
